<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>日志管理</title>
  <link rel="stylesheet" href="${ctx}/static/admin/layui/css/layui.css">
  <link rel="stylesheet" href="${ctx}/static/admin/css/common.css">
  <link rel="stylesheet" href="${ctx}/static/admin/css/sidebar.css">
</head>
  <body>
  	<div class="layui-card-body">
	  <button class="layui-btn layui-btn-sm" id="search_sidebar"><i class="layui-icon layui-icon-search"></i></button>
	    <table class="layui-hide" id="log_table"></table>
	</div>
  </body>
</html>
<script src="${ctx}/static/admin/layui/layui.js"></script>
<script src="${ctx}/static/admin/js/common.js"></script>
<script type="text/html" id="search_sidebar_tpl">
  <form class="layui-form">
    <div class="layui-form-item">
      <label class="layui-form-label">类名</label>
      <div class="layui-input-block">
        <input type="text" name="class_name" placeholder="请输入类名" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="serach_form"><i class="layui-icon">&#xe615;</i> 搜索</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
</script>
<script type="text/javascript">
layui.use(['table','layer','jquery','element','sidebar','form'], function(){
	var $ = jQuery = layui.$;
	var table = layui.table;
	var layer = layui.layer;
	var element = layui.element;
	var sidebar = layui.sidebar;
    var form = layui.form;
	var tableIns = table.render({
		elem: '#log_table',
	    cellMinWidth: 80,
	    size:'sm',
	    even:true,
	    url: '${ctx}/sys_admin/sys/log/getList',
	    height:'full-70',
	    page: true,
	    cols: [[
	      {type: 'numbers'},
	      {field: 'uid', width: '80', title: '操作人'},
	      {field: 'from', width: '180', title: '来源'},
	      {field: 'ip', width: '100', title: 'IP'},
	      {field: 'url', width: '150', title: '路径'},
	      {field: 'err_code', width: '80', title: '返回码'},
	      {field: 'err_msg', width: '150', title: '返回信息'},
	      {field: 'class_name', width: '380', title: '类名'},
	      {field: 'method_name', width: '150', title: '方法名'},
	      {field: 'start_time', width: '160', title: '开始时间'},
	      {field: 'spend_time', width: '100', title:'耗时',}
	    ]],
	    where:{
	    	sort : 'start_time',
	    	order : 'desc'
	    },
        page: {
            first: '首页',
            last: '尾页',
            prev: '上一页',
            next: '下一页',
            layout: ['limit', 'count', 'prev', 'next', 'page'] //自定义分页布局
        }
	});
	
	$('#search_sidebar').on('click', function () {
		var that = this;
		sidebar.render({
	        elem: that,
	        content: $('#search_sidebar_tpl').html(),
	        title: '搜索',
	        shade: true,
	        width: '30%', //可以设置百分比和px
	        done: function () {
				form.render();
				form.on('submit(serach_form)', function (data) {
		            table.reload('log_table', {
		            	where: {key:data.field}
		            });
	            	return false;
	          	});
			}
		});
	});
});
</script>